package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 何华树
 * Date: 2024-09-04
 * Time: 13:32
 */
class Out {
    public int a = 10;
    public void test() {
        System.out.println("对于普通类而言的匿名内部类。");
    }
}

public class Test1 {
    public static void main1(String[] args) {
        //对于普通类而言：
        new Out() { //Out out = new Out()（×）

        }.test();
        //对于接口而言：
        IA ia = new IA() {
            public void func() {
                System.out.println("对于接口的匿名内部类。");
            }
        };
        ia.func();
    }
}
